package com.jdd.modules.parkmonthly.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jdd.modules.parkmonthly.dto.MonthlyPackageInfoDTO;
import com.jdd.modules.parkmonthly.entity.MonthlyPackageInfo;
import com.jdd.modules.parkmonthly.mapper.MonthlyPackageInfoMapper;
import com.jdd.modules.parkmonthly.service.IMonthlyPackageInfoService;
import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.List;

/**
 * @Description: 月卡车部门组织表
 * @Author: jdd
 * @Date:   2021-11-09
 * @Version: V1.0
 */
@Service
public class MonthlyPackageInfoServiceImpl extends ServiceImpl<MonthlyPackageInfoMapper, MonthlyPackageInfo> implements IMonthlyPackageInfoService {

    @Override
    public void translateMonthlyPackageInfo(MonthlyPackageInfo monthlyPackageInfo, List<MonthlyPackageInfoDTO> list){
        MonthlyPackageInfoDTO monthlyPackageInfoDTO = new MonthlyPackageInfoDTO();
        monthlyPackageInfoDTO.setId(monthlyPackageInfo.getId());
        monthlyPackageInfoDTO.setParkCode(monthlyPackageInfo.getParkCode());
        monthlyPackageInfoDTO.setParkName(monthlyPackageInfo.getParkName());
        monthlyPackageInfoDTO.setPackageName(monthlyPackageInfo.getPackageName());
        monthlyPackageInfoDTO.setMonthlyTypeName(monthlyPackageInfo.getMonthlyTypeName());
        monthlyPackageInfoDTO.setMonthlyTypeId(monthlyPackageInfo.getMonthlyTypeId());
        monthlyPackageInfoDTO.setFixedSpace(monthlyPackageInfo.getFixedSpace()==1 ?"固定":"不固定");
        monthlyPackageInfoDTO.setSpaceFlag(monthlyPackageInfo.getSpaceFlag()==1 ?"一车一位":"多车多位");
        monthlyPackageInfoDTO.setBindingSpaceNumber(monthlyPackageInfo.getBindingSpaceNumber());
        monthlyPackageInfoDTO.setBindingCarNumber(monthlyPackageInfo.getBindingCarNumber());
        monthlyPackageInfoDTO.setCycleLength(monthlyPackageInfo.getCycleLength()==1?"1天":"1月");
        monthlyPackageInfoDTO.setCharges(String.valueOf(new BigDecimal(monthlyPackageInfo.getCharges()).divide(new BigDecimal(100)).setScale(2, RoundingMode.HALF_UP)));
        monthlyPackageInfoDTO.setFullManageId(monthlyPackageInfo.getFullManageId());
        monthlyPackageInfoDTO.setFullManageName(monthlyPackageInfo.getFullManageName());
        monthlyPackageInfoDTO.setOverdueTypeName(monthlyPackageInfo.getOverdueTypeName());
        monthlyPackageInfoDTO.setOverdueTypeId(monthlyPackageInfo.getOverdueTypeId());
        monthlyPackageInfoDTO.setOverdueDelayWay(monthlyPackageInfo.getOverdueDelayWay()==1 ? "顺延":"跳延");
        monthlyPackageInfoDTO.setAllowHandleStarting(monthlyPackageInfo.getAllowHandleStarting() ==1 ? "是":"否" );
        monthlyPackageInfoDTO.setAllowHandleOf(monthlyPackageInfo.getAllowHandleOf() ==1 ? "是":"否" );
        if (null==monthlyPackageInfo.getMaxCycle()){
            monthlyPackageInfoDTO.setMaxCycle("");
        }else {
            monthlyPackageInfoDTO.setMaxCycle(monthlyPackageInfo.getCycleLength() == 1 ? (int) monthlyPackageInfo.getMaxCycle() + "天" : monthlyPackageInfo.getMaxCycle() + "月");
        }
        monthlyPackageInfoDTO.setAllowOnlineBuy(monthlyPackageInfo.getAllowOnlineBuy() ==1 ? "允许":"禁止" );
        monthlyPackageInfoDTO.setAllowOnlineRenewal(monthlyPackageInfo.getAllowOnlineRenewal() ==1 ? "允许":"禁止" );
//        monthlyPackageInfoDTO.setParkingSlots(monthlyPackageInfo);
//        monthlyPackageInfoDTO.setOutsideBillingType(monthlyPackageInfo);
//        monthlyPackageInfoDTO.setWorkParkStartTime(monthlyPackageInfo);
//        monthlyPackageInfoDTO.setWorkParkEntTime();
//        monthlyPackageInfoDTO.setWeekendParkStartTime();
//        monthlyPackageInfoDTO.setWeekendParkEntTime();
//        monthlyPackageInfoDTO.setHolidaysParkStartTime();
//        monthlyPackageInfoDTO.setHolidaysParkEntTime();
        monthlyPackageInfoDTO.setRemark(monthlyPackageInfo.getRemark());
//        monthlyPackageInfoDTO.setEdition();
//        monthlyPackageInfoDTO.setApplicationStatus();
//        monthlyPackageInfoDTO.setTakeTime();
        monthlyPackageInfoDTO.setImageUrl(monthlyPackageInfo.getImageUrl());
        monthlyPackageInfoDTO.setCreateUserId(monthlyPackageInfo.getCreateUserId());
        monthlyPackageInfoDTO.setCreateUserName(monthlyPackageInfo.getCreateUserName());
        monthlyPackageInfoDTO.setCreateTime(monthlyPackageInfo.getCreateTime());
        monthlyPackageInfoDTO.setUpdateUserId(monthlyPackageInfo.getUpdateUserId());
        monthlyPackageInfoDTO.setUpdateUserName(monthlyPackageInfo.getUpdateUserName());
        monthlyPackageInfoDTO.setUpdateTime(monthlyPackageInfo.getUpdateTime());

        list.add(monthlyPackageInfoDTO);
    }
}
